import axios from "axios"

export function $get(url,data){
    return $request(url,'get',data)
}

export function $post(url,data){
    return $request(url,'post',data)
}

export function $request(url,method,data){
    return new Promise((resolve,reject)=>{ 
        axios({
                url,
                method,
                data
            }).then((res)=>{
                resolve(res.data)
            }).catch(err=>{
                reject(err)
        })
    })
}







//作废


let baseURL = ''

const $http = axios.create({
    baseURL
})

export const get =(url,params)=>{
    params = params || {};
    return new Promise((resolve,reject)=>{
        $http.get(url,{
            params
        }).then(res=>{
            resolve(res.data)
        }).catch(err=>{
            reject(err)
        })
    })
}

export const post = (url,params)=>{
    params = params || {};
    return new Promise((resolve,reject)=>{
        $http.post(url,params).then(res=>{
            resolve(res.data)
        }).catch(err=>{
            reject(err)
        })
    })
}

